<!DOCTYPE HTML>
<html>
<head>
<title>FileGetTime | AutoHotkey</title>
<meta name="description" content="The FileGetTime command retrieves the datetime stamp of a file or folder." />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>FileGetTime</h1>

<p>获取文件或文件夹的时间戳.</p>

<pre class="Syntax"><span class="func">FileGetTime</span>, OutputVar <span class="optional">, Filename, WhichTime</span></pre>
<h2>参数</h2>
<dl>

  <dt>OutputVar</dt>
  <dd><p>用来保存获取的 <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> 格式的日期时间的变量名. 这个时间是您的本地时间, 不是 UTC/GMT.</p></dd>

  <dt>Filename</dt>
  <dd><p>目标文件或文件夹的名称, 如果未指定绝对路径, 则假定在 <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> 中. 如果省略, 则使用最内层<a href="LoopFile.htm">文件循环</a>的当前文件.</p></dd>

  <dt>WhichTime</dt>
  <dd>要获取的时间戳类别:<br>M = 修改时间(此参数省略时这是默认的)<br>C = 创建时间<br>A = 上次访问时间</dd>

</dl>

<h2>错误处理</h2>
<p><span class="ver">[v1.1.04+]</span>: 此命令失败时会抛出异常. 想了解更多信息, 请参阅<a href="Catch.htm#RuntimeErrors">运行时错误</a>.</p>
<p>如果遇到问题则 <a href="../misc/ErrorLevel.htm">ErrorLevel</a> 被置为 1, 否则为 0.</p>
<p><a href="../Variables.htm#LastError">A_LastError</a> 被设置为操作系统 GetLastError() 函数返回的结果.</p>

<h2>备注</h2>
<p>请参阅 <a href="FileSetTime.htm#YYYYMMDD">YYYYMMDDHH24MISS</a> 了解日期和时间的说明.</p>
<h2>相关</h2>
<p><a href="FileSetTime.htm">FileSetTime</a>, <a href="FormatTime.htm">FormatTime</a>, <a href="IfIs.htm">If var is [not] type</a>, <a href="FileGetAttrib.htm">FileGetAttrib</a>, <a href="FileSetAttrib.htm">FileSetAttrib</a>, <a href="FileGetSize.htm">FileGetSize</a>, <a href="FileGetVersion.htm">FileGetVersion</a>, <a href="LoopFile.htm">文件循环</a>, <a href="EnvAdd.htm">EnvAdd (时间计算)</a>, <a href="EnvSub.htm">EnvSub (时间比较)</a></p>
<h3>示例</h3>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>FileGetTime, OutputVar, C:\My Documents\test.doc  <em>; 默认获取修改时间.</em>
FileGetTime, OutputVar, C:\My Documents\test.doc, C  <em>; 获取创建时间.</em></pre>
</div>

</body>
</html>